//package com.ddwl.common.config;
//
//import com.alibaba.cloud.nacos.registry.NacosRegistration;
//import com.alibaba.cloud.nacos.registry.NacosServiceRegistry;
//import com.alibaba.fastjson.JSON;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.context.ApplicationListener;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.event.ContextClosedEvent;
//import org.springframework.core.annotation.Order;
//
//import javax.annotation.Resource;
//
///**
// * 类GracefulShutdown.java的实现描述：下线服务并延迟关闭spring boot
// *
// * @author zach
// * @Date :2019-06-17 07:14.
// */
//@Slf4j
//@Order
//@Configuration
//public class GracefulShutdown implements  ApplicationListener<ContextClosedEvent> {
//
//    @Resource
//    private NacosServiceRegistry nacosServiceRegistry;
//    @Resource
//    private NacosRegistration nacosRegistration;
//
//    @Override
//    public void onApplicationEvent(ContextClosedEvent event) {
//        log.info("开始下线服务 nacosRegistration={}", JSON.toJSONString(nacosRegistration));
//        try {
//            nacosServiceRegistry.setStatus(nacosRegistration,"DOWN");
//            log.info("开始下线服务成功");
//            //秒延迟10秒停止服务
//            Thread.sleep(10000L);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        log.info("开始下线服务结束");
//    }
//
//}
